package com.seecoder.BlueWhale.po;

import com.seecoder.BlueWhale.enums.CouponGroupStatusEnum;
import com.seecoder.BlueWhale.enums.CouponTypeEnum;
import com.seecoder.BlueWhale.enums.CouponScopeEnum;
import com.seecoder.BlueWhale.enums.UserStatusEnum;
import com.seecoder.BlueWhale.vo.CouponGroupVO;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import javax.persistence.*;
import java.util.List;

@Entity
@Setter
@Getter
@NoArgsConstructor
@Table(name = "coupon_group", indexes = {@Index(columnList = "store_id")})
public class CouponGroup {
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Id
    @Column(name = "id")
    private int id;

    @Basic
    @Column(name = "coupon_count")
    private int couponCount;

    @Basic
    @Column(name = "coupon_scope")
    private CouponScopeEnum couponScope;

    @Basic
    @Column(name = "coupon_type")
    private CouponTypeEnum couponType;

    @Basic
    @Column(name = "coupon_group_status")
    private CouponGroupStatusEnum couponGroupStatusEnum;

    @Basic
    @Column(name = "store_id")
    private int storeId;

    @Basic
    @Column(name = "full_amount")
    private double fullAmount;

    @Basic
    @Column(name = "discount_amount")
    private double discountAmount;

    @Basic
    @Column(name = "received_count")
    private int receivedCount;

    @ElementCollection
    @Column(name = "user_id")
    private List<Integer> userId;

    public CouponGroupVO toVO() {
        return new CouponGroupVO(this.id, this.couponCount, this.couponScope, this.couponType,
                this.couponGroupStatusEnum, UserStatusEnum.NOT_RECEIVED,
                this.storeId, this.fullAmount, this.discountAmount, this.receivedCount);
    }
}
